
<?php
include_once 'inc/config.inc.php';
include_once 'inc/mysql.inc.php';
include_once 'inc/tool.inc.php';
include_once 'inc/page.inc.php';
$link=connect();
$member_id=is_login($link);
$template['title']='会员中心';
$template['css']=array('style/public.css','style/list.css','style/member.css');
include ("inc/header.inc.php");
// 会员信息
if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    skip('index.php','error','未找到该会员记录');
}
$query = "SELECT name,photo from sfk_member WHERE id = {$_GET['id']} limit 1";
$user = execute($link,$query);
$user = $user->fetch_array();

$query = "SELECT count(id) FROM sfk_content WHERE member_id = {$_GET['id']}";
$number = execute($link,$query)->fetch_array();

// 分页
$page = page($number['count(id)'], 5);

// 用户所发布的所有帖子
$query = "SELECT c.id, c.title, c.time, c.times FROM sfk_content c WHERE c.member_id = {$_GET['id']} order by c.time desc {$page['limit']}";
$content = execute($link,$query);
?>
<div style="margin-top:55px;"></div>
<div id="position" class="auto">
    <a href="index.php">首页</a> &gt; <?=$user['name']?>的会员中心
</div>
<div id="main" class="auto">
    <div id="right">
        <div class="member_big">
            <dl>
                <dt>
                    <img width="180" height="180" src="<?php if($user['photo']!=''){echo $user['photo'];}else{echo 'style/photo.jpg';}?>" />
                </dt>
                <dd class="name"><?=$user['name']?></dd>
                <dd>帖子总计：<?=$number['count(id)']?></dd>
                <!--<dd>操作：<a target="_blank" href="">修改头像</a> | <a target="_blank" href="">修改密码</a></dd>-->
            </dl>
            <div style="clear:both;"></div>
        </div>
    </div>
    <div id="left">
        <?php
        while ($data = $content->fetch_array()) {
            $data['title'] = htmlspecialchars($data['title']);
            $query = "select count(id) from sfk_reply where content_id = {$data['id']}";
            $rows = execute($link,$query)->fetch_array();
            ?>
        <ul class="postsList">
            <li>
                <div class="smallPic">
                    <a href="#">
                        <img width="45" height="45" src="<?php if($user['photo']!=''){echo $user['photo'];}else{echo 'style/photo.jpg';}?>" />
                    </a>
                </div>
                <div class="subject">
                    <div class="titleWrap"><h2><a href="show.php?id=<?=$data['id']?>"><?=$data['title']?></a></h2></div>
                    <p>
                        <?php
                            if ($user['name'] == $_COOKIE['sfk']['name']) {
                               echo "<a target='_blank' href='content_update.php?id={$data['id']}'>修改</a> | <a href=''>删除</a>";
                            }
                        ?>
                        发布时间：<?=$data['time']?>
                    </p>
                </div>
                <div class="count">
                    <p>
                        回复<br /><span><?=$rows['count(id)']?></span>
                    </p>
                    <p>
                        浏览<br /><span><?=$data['times']?></span>
                    </p>
                </div>
                <div style="clear:both;"></div>
            </li>
        </ul>
        <?php
        }
        ?>
        <div class="pages">
            <?=$page['html']?>
        </div>
    </div>

    <div style="clear:both;"></div>
</div>
<?php
    include ("inc/footer.inc.php");
?>